<!-- src/components/Settings.vue -->
<template>
  <div class="settings">
    <!-- 设置导航 -->
    <div class="settings-nav">
      <button 
        v-for="tab in settingTabs" 
        :key="tab.key"
        @click="activeTab = tab.key"
        :class="['nav-tab', { active: activeTab === tab.key }]"
      >
        <i :class="tab.icon"></i>
        {{ tab.label }}
      </button>
    </div>

    <!-- 设置内容 -->
    <div class="settings-content">
      <!-- 基本设置 -->
      <div v-if="activeTab === 'basic'" class="setting-section">
        <div class="section-header">
          <h3>基本设置</h3>
          <p>配置系统的基本信息和参数</p>
        </div>
        
        <div class="setting-form">
          <div class="form-group">
            <label>系统名称</label>
            <input 
              v-model="settings.basic.systemName" 
              type="text" 
              placeholder="请输入系统名称"
            />
            <small>显示在页面标题和登录页面的系统名称</small>
          </div>
          
          <div class="form-group">
            <label>系统Logo</label>
            <div class="logo-upload">
              <img :src="settings.basic.logo || '/default-logo.png'" alt="Logo" class="logo-preview" />
              <div class="upload-actions">
                <button @click="uploadLogo" class="btn btn-outline">
                  <i class="icon-upload"></i>上传Logo
                </button>
                <input 
                  v-model="settings.basic.logo" 
                  type="url" 
                  placeholder="或输入Logo URL"
                  class="logo-url"
                />
              </div>
            </div>
          </div>
          
          <div class="form-group">
            <label>系统描述</label>
            <textarea 
              v-model="settings.basic.description" 
              rows="3"
              placeholder="请输入系统描述"
            ></textarea>
          </div>
          
          <div class="form-group">
            <label>联系信息</label>
            <div class="contact-inputs">
              <input 
                v-model="settings.basic.contact.phone" 
                type="tel" 
                placeholder="联系电话"
              />
              <input 
                v-model="settings.basic.contact.email" 
                type="email" 
                placeholder="联系邮箱"
              />
              <input 
                v-model="settings.basic.contact.address" 
                type="text" 
                placeholder="联系地址"
              />
            </div>
          </div>
          
          <div class="form-actions">
            <button @click="saveBasicSettings" class="btn btn-primary" :disabled="saving">
              {{ saving ? '保存中...' : '保存设置' }}
            </button>
          </div>
        </div>
      </div>

      <!-- 用户管理 -->
      <div v-if="activeTab === 'users'" class="setting-section">
        <div class="section-header">
          <h3>用户管理</h3>
          <p>管理系统用户和权限</p>
          <button @click="showAddUserModal = true" class="btn btn-primary">
            <i class="icon-plus"></i>添加用户
          </button>
        </div>
        
        <div class="users-table">
          <table class="data-table">
            <thead>
              <tr>
                <th>用户名</th>
                <th>姓名</th>
                <th>角色</th>
                <th>邮箱</th>
                <th>状态</th>
                <th>最后登录</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="user in users" :key="user.id">
                <td>{{ user.username }}</td>
                <td>{{ user.name }}</td>
                <td>
                  <span class="role-badge" :class="user.role">
                    {{ getRoleName(user.role) }}
                  </span>
                </td>
                <td>{{ user.email }}</td>
                <td>
                  <span class="status-badge" :class="{ active: user.is_active }">
                    {{ user.is_active ? '启用' : '禁用' }}
                  </span>
                </td>
                <td>{{ formatDate(user.last_login) }}</td>
                <td>
                  <div class="action-buttons">
                    <button @click="editUser(user)" class="btn-icon" title="编辑">
                      <i class="icon-edit"></i>
                    </button>
                    <button 
                      @click="toggleUserStatus(user)" 
                      :class="['btn-icon', user.is_active ? 'danger' : 'success']" 
                      :title="user.is_active ? '禁用' : '启用'"
                    >
                      <i :class="user.is_active ? 'icon-user-x' : 'icon-user-check'"></i>
                    </button>
                    <button @click="deleteUser(user)" class="btn-icon danger" title="删除">
                      <i class="icon-trash"></i>
                    </button>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>

      <!-- 数据管理 -->
      <div v-if="activeTab === 'data'" class="setting-section">
        <div class="section-header">
          <h3>数据管理</h3>
          <p>数据备份、恢复和清理</p>
        </div>
        
        <div class="data-management">
          <div class="management-card">
            <div class="card-header">
              <h4>数据备份</h4>
              <i class="icon-database"></i>
            </div>
            <div class="card-content">
              <p>定期备份系统数据，确保数据安全</p>
              <div class="backup-options">
                <div class="option-item">
                  <label>
                    <input type="checkbox" v-model="settings.data.autoBackup" />
                    启用自动备份
                  </label>
                </div>
                <div class="option-item">
                  <label>备份频率：</label>
                  <select v-model="settings.data.backupFrequency">
                    <option value="daily">每日</option>
                    <option value="weekly">每周</option>
                    <option value="monthly">每月</option>
                  </select>
                </div>
              </div>
              <div class="card-actions">
                <button @click="createBackup" class="btn btn-primary">
                  <i class="icon-download"></i>立即备份
                </button>
                <button @click="showBackupHistory = true" class="btn btn-outline">
                  查看备份历史
                </button>
              </div>
            </div>
          </div>

          <div class="management-card">
            <div class="card-header">
              <h4>数据恢复</h4>
              <i class="icon-refresh-cw"></i>
            </div>
            <div class="card-content">
              <p>从备份文件恢复系统数据</p>
              <div class="restore-upload">
                <input type="file" id="restore-file" accept=".sql,.zip" style="display: none" />
                <button @click="selectRestoreFile" class="btn btn-outline">
                  <i class="icon-upload"></i>选择备份文件
                </button>
                <span v-if="restoreFile" class="file-name">{{ restoreFile.name }}</span>
              </div>
              <div class="card-actions">
                <button 
                  @click="restoreData" 
                  :disabled="!restoreFile"
                  class="btn btn-primary"
                >
                  <i class="icon-refresh-cw"></i>恢复数据
                </button>
              </div>
            </div>
          </div>

          <div class="management-card">
            <div class="card-header">
              <h4>数据清理</h4>
              <i class="icon-trash-2"></i>
            </div>
            <div class="card-content">
              <p>清理过期和无用的数据</p>
              <div class="cleanup-options">
                <div class="option-item">
                  <label>
                    <input type="checkbox" v-model="settings.data.cleanupLogs" />
                    清理30天前的日志
                  </label>
                </div>
                <div class="option-item">
                  <label>
                    <input type="checkbox" v-model="settings.data.cleanupTemp" />
                    清理临时文件
                  </label>
                </div>
                <div class="option-item">
                  <label>
                    <input type="checkbox" v-model="settings.data.cleanupCache" />
                    清理缓存文件
                  </label>
                </div>
              </div>
              <div class="card-actions">
                <button @click="cleanupData" class="btn btn-danger">
                  <i class="icon-trash-2"></i>开始清理
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 系统配置 -->
      <div v-if="activeTab === 'system'" class="setting-section">
        <div class="section-header">
          <h3>系统配置</h3>
          <p>系统运行参数和安全设置</p>
        </div>
        
        <div class="system-config">
          <div class="config-group">
            <h4>安全设置</h4>
            <div class="config-items">
              <div class="config-item">
                <label>密码最小长度</label>
                <input 
                  v-model.number="settings.system.security.minPasswordLength" 
                  type="number" 
                  min="6" 
                  max="20"
                />
              </div>
              <div class="config-item">
                <label>登录失败锁定次数</label>
                <input 
                  v-model.number="settings.system.security.maxLoginAttempts" 
                  type="number" 
                  min="3" 
                  max="10"
                />
              </div>
              <div class="config-item">
                <label>会话超时时间（分钟）</label>
                <input 
                  v-model.number="settings.system.security.sessionTimeout" 
                  type="number" 
                  min="30" 
                  max="1440"
                />
              </div>
              <div class="config-item">
                <label class="checkbox-label">
                  <input type="checkbox" v-model="settings.system.security.enableTwoFactor" />
                  启用双因素认证
                </label>
              </div>
            </div>
          </div>

          <div class="config-group">
            <h4>性能设置</h4>
            <div class="config-items">
              <div class="config-item">
                <label>每页显示条数</label>
                <select v-model="settings.system.performance.pageSize">
                  <option value="10">10</option>
                  <option value="20">20</option>
                  <option value="50">50</option>
                  <option value="100">100</option>
                </select>
              </div>
              <div class="config-item">
                <label>缓存过期时间（小时）</label>
                <input 
                  v-model.number="settings.system.performance.cacheExpiration" 
                  type="number" 
                  min="1" 
                  max="168"
                />
              </div>
              <div class="config-item">
                <label class="checkbox-label">
                  <input type="checkbox" v-model="settings.system.performance.enableCache" />
                  启用数据缓存
                </label>
              </div>
            </div>
          </div>

          <div class="config-actions">
            <button @click="saveSystemSettings" class="btn btn-primary" :disabled="saving">
              {{ saving ? '保存中...' : '保存配置' }}
            </button>
            <button @click="resetSystemSettings" class="btn btn-secondary">
              恢复默认
            </button>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加用户模态框 -->
    <div v-if="showAddUserModal || showEditUserModal" class="modal-overlay" @click="closeUserModals">
      <div class="modal" @click.stop>
        <div class="modal-header">
          <h3>{{ showAddUserModal ? '添加用户' : '编辑用户' }}</h3>
          <button @click="closeUserModals" class="modal-close">
            <i class="icon-x"></i>
          </button>
        </div>
        
        <div class="modal-body">
          <form @submit.prevent="saveUser">
            <div class="form-group">
              <label>用户名 *</label>
              <input
                v-model="userForm.username"
                type="text"
                required
                :disabled="showEditUserModal"
                placeholder="请输入用户名"
              />
            </div>
            
            <div class="form-group">
              <label>姓名 *</label>
              <input
                v-model="userForm.name"
                type="text"
                required
                placeholder="请输入姓名"
              />
            </div>
            
            <div class="form-group">
              <label>邮箱 *</label>
              <input
                v-model="userForm.email"
                type="email"
                required
                placeholder="请输入邮箱"
              />
            </div>
            
            <div class="form-group">
              <label>角色 *</label>
              <select v-model="userForm.role" required>
                <option value="">请选择角色</option>
                <option value="admin">管理员</option>
                <option value="manager">管理者</option>
                <option value="operator">操作员</option>
              </select>
            </div>
            
            <div class="form-group" v-if="showAddUserModal">
              <label>密码 *</label>
              <input
                v-model="userForm.password"
                type="password"
                required
                placeholder="请输入密码"
              />
            </div>
            
            <div class="modal-footer">
              <button type="button" @click="closeUserModals" class="btn btn-secondary">取消</button>
              <button type="submit" class="btn btn-primary" :disabled="saving">
                {{ saving ? '保存中...' : '保存' }}
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'

// 响应式数据
const activeTab = ref('basic')
const saving = ref(false)
const showAddUserModal = ref(false)
const showEditUserModal = ref(false)
const showBackupHistory = ref(false)
const restoreFile = ref(null)

// 设置标签
const settingTabs = [
  { key: 'basic', label: '基本设置', icon: 'icon-settings' },
  { key: 'users', label: '用户管理', icon: 'icon-users' },
  { key: 'data', label: '数据管理', icon: 'icon-database' },
  { key: 'system', label: '系统配置', icon: 'icon-cpu' }
]

// 设置数据
const settings = reactive({
  basic: {
    systemName: '农民技能提升就业培训大数据平台',
    logo: '',
    description: '专注于农民技能提升和就业培训的综合管理平台',
    contact: {
      phone: '',
      email: '',
      address: ''
    }
  },
  data: {
    autoBackup: true,
    backupFrequency: 'daily',
    cleanupLogs: true,
    cleanupTemp: true,
    cleanupCache: false
  },
  system: {
    security: {
      minPasswordLength: 8,
      maxLoginAttempts: 5,
      sessionTimeout: 120,
      enableTwoFactor: false
    },
    performance: {
      pageSize: 20,
      cacheExpiration: 24,
      enableCache: true
    }
  }
})

// 用户数据
const users = ref([
  {
    id: 1,
    username: 'admin',
    name: '系统管理员',
    email: 'admin@example.com',
    role: 'admin',
    is_active: true,
    last_login: '2024-01-15T10:30:00'
  },
  {
    id: 2,
    username: 'manager',
    name: '李经理',
    email: 'manager@example.com',
    role: 'manager',
    is_active: true,
    last_login: '2024-01-14T16:20:00'
  },
  {
    id: 3,
    username: 'operator',
    name: '张操作员',
    email: 'operator@example.com',
    role: 'operator',
    is_active: false,
    last_login: '2024-01-10T09:15:00'
  }
])

// 用户表单
const userForm = reactive({
  username: '',
  name: '',
  email: '',
  role: '',
  password: ''
})

const selectedUser = ref(null)

// 方法
const saveBasicSettings = async () => {
  saving.value = true
  try {
    await new Promise(resolve => setTimeout(resolve, 1000))
    console.log('保存基本设置', settings.basic)
    alert('基本设置保存成功')
  } catch (error) {
    console.error('保存失败:', error)
    alert('保存失败，请重试')
  } finally {
    saving.value = false
  }
}

const saveSystemSettings = async () => {
  saving.value = true
  try {
    await new Promise(resolve => setTimeout(resolve, 1000))
    console.log('保存系统配置', settings.system)
    alert('系统配置保存成功')
  } catch (error) {
    console.error('保存失败:', error)
    alert('保存失败，请重试')
  } finally {
    saving.value = false
  }
}

const resetSystemSettings = () => {
  if (confirm('确定要恢复系统默认配置吗？')) {
    Object.assign(settings.system, {
      security: {
        minPasswordLength: 8,
        maxLoginAttempts: 5,
        sessionTimeout: 120,
        enableTwoFactor: false
      },
      performance: {
        pageSize: 20,
        cacheExpiration: 24,
        enableCache: true
      }
    })
  }
}

const uploadLogo = () => {
  const input = document.createElement('input')
  input.type = 'file'
  input.accept = 'image/*'
  input.onchange = (e) => {
    const file = e.target.files[0]
    if (file) {
      // 这里应该上传文件到服务器
      console.log('上传Logo文件:', file)
      // 模拟上传成功
      settings.basic.logo = URL.createObjectURL(file)
    }
  }
  input.click()
}

const editUser = (user) => {
  selectedUser.value = user
  Object.assign(userForm, {
    username: user.username,
    name: user.name,
    email: user.email,
    role: user.role,
    password: ''
  })
  showEditUserModal.value = true
}

const saveUser = async () => {
  saving.value = true
  try {
    await new Promise(resolve => setTimeout(resolve, 1000))
    
    if (showAddUserModal.value) {
      // 添加用户
      const newUser = {
        id: Date.now(),
        ...userForm,
        is_active: true,
        last_login: null
      }
      users.value.push(newUser)
    } else {
      // 编辑用户
      const index = users.value.findIndex(u => u.id === selectedUser.value.id)
      if (index !== -1) {
        Object.assign(users.value[index], userForm)
      }
    }
    
    closeUserModals()
    alert('用户保存成功')
  } catch (error) {
    console.error('保存用户失败:', error)
    alert('保存失败，请重试')
  } finally {
    saving.value = false
  }
}

const toggleUserStatus = async (user) => {
  try {
    user.is_active = !user.is_active
    console.log('切换用户状态:', user.id, user.is_active)
    alert(`用户已${user.is_active ? '启用' : '禁用'}`)
  } catch (error) {
    console.error('切换用户状态失败:', error)
    alert('操作失败，请重试')
  }
}

const deleteUser = async (user) => {
  if (confirm(`确定要删除用户 ${user.name} 吗？`)) {
    try {
      const index = users.value.findIndex(u => u.id === user.id)
      users.value.splice(index, 1)
      alert('用户删除成功')
    } catch (error) {
      console.error('删除用户失败:', error)
      alert('删除失败，请重试')
    }
  }
}

const closeUserModals = () => {
  showAddUserModal.value = false
  showEditUserModal.value = false
  selectedUser.value = null
  Object.assign(userForm, {
    username: '',
    name: '',
    email: '',
    role: '',
    password: ''
  })
}

const createBackup = async () => {
  try {
    console.log('创建数据备份')
    alert('备份创建成功')
  } catch (error) {
    console.error('备份失败:', error)
    alert('备份失败，请重试')
  }
}

const selectRestoreFile = () => {
  const input = document.getElementById('restore-file')
  input.onchange = (e) => {
    restoreFile.value = e.target.files[0]
  }
  input.click()
}

const restoreData = async () => {
  if (!restoreFile.value) return
  
  if (confirm('确定要恢复数据吗？此操作将覆盖现有数据！')) {
    try {
      console.log('恢复数据:', restoreFile.value.name)
      alert('数据恢复成功')
      restoreFile.value = null
    } catch (error) {
      console.error('恢复失败:', error)
      alert('恢复失败，请重试')
    }
  }
}

const cleanupData = async () => {
  if (confirm('确定要清理数据吗？')) {
    try {
      console.log('清理数据:', settings.data)
      alert('数据清理成功')
    } catch (error) {
      console.error('清理失败:', error)
      alert('清理失败，请重试')
    }
  }
}

const getRoleName = (role) => {
  const roles = {
    admin: '管理员',
    manager: '管理者',
    operator: '操作员'
  }
  return roles[role] || role
}

const formatDate = (date) => {
  if (!date) return '从未登录'
  return new Date(date).toLocaleString('zh-CN')
}

// 生命周期
onMounted(() => {
  // 加载设置数据
  console.log('加载系统设置')
})
</script>

<style scoped>
.settings {
  padding: 20px;
}

.settings-nav {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 24px;
  padding: 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  background: #F3F4F6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #6B7280;
  transition: all 0.2s;
}

.nav-tab:hover {
  background: #E5E7EB;
  color: #374151;
}

.nav-tab.active {
  background: #4F46E5;
  color: white;
}

.settings-content {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.setting-section {
  padding: 24px;
}

.section-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h3 {
  margin: 0 0 8px 0;
  color: #1F2937;
  font-size: 20px;
}

.section-header p {
  margin: 0;
  color: #6B7280;
  font-size: 14px;
}

.setting-form {
  max-width: 600px;
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4F46E5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: #6B7280;
  font-size: 12px;
}

.logo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-preview {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  background: #F9FAFB;
}

.upload-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-url {
  width: 300px;
}

.contact-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-actions {
  margin-top: 32px;
}

.users-table {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #E5E7EB;
}

.data-table th {
  background: #F9FAFB;
  font-weight: 600;
  color: #374151;
}

.role-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.role-badge.admin {
  background: #FEE2E2;
  color: #DC2626;
}

.role-badge.manager {
  background: #FEF3C7;
  color: #92400E;
}

.role-badge.operator {
  background: #D1FAE5;
  color: #065F46;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #FEE2E2;
  color: #DC2626;
}

.status-badge.active {
  background: #D1FAE5;
  color: #065F46;
}

.action-buttons {
  display: flex;
  gap: 4px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: #F3F4F6;
  color: #6B7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #E5E7EB;
  color: #374151;
}

.btn-icon.success {
  background: #D1FAE5;
  color: #065F46;
}

.btn-icon.danger {
  background: #FEE2E2;
  color: #DC2626;
}

.data-management {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.management-card {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h4 {
  margin: 0;
  color: #1F2937;
}

.card-header i {
  color: #6B7280;
  font-size: 20px;
}

.card-content p {
  margin: 0 0 16px 0;
  color: #6B7280;
  font-size: 14px;
}

.backup-options,
.cleanup-options {
  margin-bottom: 16px;
}

.option-item {
  margin-bottom: 8px;
}

.option-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
}

.restore-upload {
  margin-bottom: 16px;
}

.file-name {
  margin-left: 12px;
  font-size: 14px;
  color: #6B7280;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.system-config {
  max-width: 800px;
}

.config-group {
  margin-bottom: 32px;
}

.config-group h4 {
  margin: 0 0 16px 0;
  color: #1F2937;
  font-size: 16px;
}

.config-items {
  display: grid;
  gap: 16px;
}

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.config-item label {
  font-size: 14px;
  color: #374151;
  margin: 0;
}

.config-item input,
.config-item select {
  width: 150px;
  flex-shrink: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.config-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: #4F46E5;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #4338CA;
}

.btn-secondary {
  background: #F3F4F6;
  color: #374151;
  border: 1px solid #D1D5DB;
}

.btn-secondary:hover {
  background: #E5E7EB;
}

.btn-outline {
  background: white;
  color: #4F46E5;
  border: 1px solid #4F46E5;
}

.btn-outline:hover {
  background: #4F46E5;
  color: white;
}

.btn-danger {
  background: #EF4444;
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* 模态框样式复用之前的... */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #1F2937;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #6B7280;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid #E5E7EB;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .settings-nav {
    flex-direction: column;
  }
  
  .nav-tab {
    width: 100%;
    justify-content: center;
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .config-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .config-item input,
  .config-item select {
    width: 100%;
  }
  
  .data-management {
    grid-template-columns: 1fr;
  }
  
  .card-actions {
    flex-direction: column;
  }
  
  .config-actions {
    flex-direction: column;
  }
}
</style>